var login = {

// 检查表单
    checkFrom: function () {
        $("#msg").addClass("hidden")
        var form = $("#loginForm");
        if (form == null) return;

        var json = JWB.utils.fromSerialize(form);
        var flag = true;
        if (json["maintainer.account"] == '') {
            $("#account").parent().addClass("has-error");
            flag = false;
        } else {
            $("#account").parent().removeClass("has-error");
        }
        if (json["maintainer.password"] == '') {
            $("#password").parent().addClass("has-error");
            flag = false;
        } else {
            $("#password").parent().removeClass("has-error");
        }
        return flag;
    }
    ,
// 提交登录
    submitLogin: function () {
        var form = $("#loginForm");
        var json = JWB.utils.fromSerialize(form);

        if (login.checkFrom() == false) return;

        var url = $("#loginBtn").attr("submitUrl");
        $.ajax({
            url: url,
            data: json,
            type: "POST",
            success: function (res) {
                if (res.code == 0) {
                    // 成功了，跳转主页
                    location.href = base.basePath + "page/index.cgi"
                } else {
                    $("#msg").html(res.msg);
                    $("#msg").removeClass("hidden")
                }
            },
            error: function (jXHR, textStatus, errorThrown) {

                if (jXHR.status == 401) {
                    $("#msg").html("用户名或者密码不正确!");
                    $("#msg").removeClass("hidden")
                }

            }
        });
    }


}


